	.text

/* Switch from current_thread to next_thread. Make next_thread
 * the current_thread, and set next_thread to 0.
 * Use eax as a temporary register; it is caller saved.
 */
	.globl thread_switch
thread_switch:
    /* 保存当前用户进程寄存器 */
	pushal           

	/* 保存当前用户进程 esp */
	movl    current_thread, %eax 
	movl    %esp, (%eax)

	/* 执行用户进程切换 */
	movl    next_thread, %eax
	movl    %eax, current_thread
	movl    $0, next_thread

	/* 取出当前用户进程的 esp */
	movl    current_thread, %eax
	movl	(%eax), %esp

	/* 恢复当前用户进程寄存器 */
	popal

	/* 跳转回用户进程 */
	ret
